package com.cloudsigns.factorymanager2.produce.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.cloudsigns.factorymanager2.BaseActivity;
import com.cloudsigns.factorymanager2.R;
import com.cloudsigns.factorymanager2.operate_maintain.util.CalendarUtil;
import com.cloudsigns.factorymanager2.operate_maintain.util.MyGridview;
import com.cloudsigns.factorymanager2.produce.adapter.ProduceAttendanceCalendarAdapter;
import com.cloudsigns.factorymanager2.project.customview.GlideCircleTransform;

public class ProduceAttendanceActivity extends BaseActivity{
    private RelativeLayout rl_back;
    private TextView tv_title;
    private ImageView img_personnel_head;
    private TextView tv_personnel_name;

    private String avatarUrl,accountName;

    private MyGridview gridView;
    private ProduceAttendanceCalendarAdapter adapter;
    private int year;
    private int month;
    private int[][] days = new int[5][7];


    @Override
    protected void onBaseCreate(Bundle savedInstanceState) {
        setContentView(R.layout.layout_produce_attendance);
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        rl_back = findViewById(R.id.rl_back);
        tv_title = findViewById(R.id.tv_title);
        img_personnel_head=findViewById(R.id.img_personnel_head);
        tv_personnel_name=findViewById(R.id.tv_personnel_name);
        gridView=findViewById(R.id.calendar_gridView);

    }

    @Override
    protected void initData(Bundle savedInstanceState) {
        tv_title.setText(getResources().getString(R.string.production_attendance));

        Intent intent=getIntent();
        avatarUrl=intent.getStringExtra("avatarUrl");
        accountName=intent.getStringExtra("accountName");

        Glide.with(ProduceAttendanceActivity.this).load(avatarUrl).bitmapTransform(new GlideCircleTransform(ProduceAttendanceActivity.this)).crossFade(1000).error(R.mipmap.default_avatar).into(img_personnel_head);
        tv_personnel_name.setText(accountName);

        year = CalendarUtil.getYear();
        month = CalendarUtil.getMonth();
        days = CalendarUtil.getDayOfMonthFormat(year, month);
        adapter = new ProduceAttendanceCalendarAdapter(ProduceAttendanceActivity.this, days, year, month);//传入当前月的年
        gridView.setAdapter(adapter);
        gridView.setEnabled(false);
    }

    @Override
    public void setListener() {
        rl_back.setOnClickListener(this);
    }

    @Override
    public void widgetClick(View view) {
        Intent mIntent;
        switch (view.getId()) {
            case R.id.rl_back:
                finish();
                break;
        }
    }
}
